<template>
    <el-form :model="form" label-width="auto" style="max-width: 600px">
        <el-form-item label="权限名称:">
            <el-input v-model="form.permissionName" />
        </el-form-item>

        <el-form-item label="权限URL:">
            <el-input v-model="form.permissionNo" />
        </el-form-item>

        <el-form-item label="权限序号:">
            <el-input v-model="form.permissionType" />
        </el-form-item>

        <el-form-item>
            <el-button type="primary" @click="onSubmit">保存</el-button>
            <el-button type="info" @click="addInfo()">返回</el-button>
        </el-form-item>
    </el-form>
</template>

<script lang="ts" setup>
import { reactive,ref } from 'vue'

import { xieInfo } from '@/Http/axiosInfo'
import { ElMessage } from 'element-plus'
import { useRouter } from 'vue-router'
const router = useRouter()
// do not use same name with ref
const form = reactive({
   
    permissionType: '',
    "permissionNo": "",
    "permissionName": ""
})

const onSubmit = () => {
    console.log('submit!')
    xieInfo.post('/Mang/AddPermission', {
        permissionData: form
    })
    .then((res) => {
        if (res.data.code == 200) {
            ElMessage.success('添加成功');
            router.push('/GetPermission')
        }
        else {
            ElMessage.error('添加失败')
        }
    })
}

const addInfo = () => {
    router.push({ path: '/GetPermission' })
}

</script>
